package com.craftplay.dao;

import com.craftplay.model.ClassType;
import com.craftplay.model.Enroll;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface ClassTypeMapper {

    @Results({
            @Result(column = "class_type", property = "classType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_desc", property = "classDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_type", property = "classTreeType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_tree_desc", property = "classTreeDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_money", property = "classTreeMoney", jdbcType = JdbcType.INTEGER)
    })
    @Select({
            "SELECT class_type,class_desc FROM class_type GROUP BY class_type"
    })
    List<ClassType> selectByClassType();

    @Results({
            @Result(column = "class_type", property = "classType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_desc", property = "classDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_type", property = "classTreeType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_tree_desc", property = "classTreeDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_money", property = "classTreeMoney", jdbcType = JdbcType.INTEGER)
    })
    @Select({
            "SELECT * FROM class_type where class_type =#{classType}"
    })
    List<ClassType> selectByClassTree(int classType);

    @Results({
            @Result(column = "class_type", property = "classType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_desc", property = "classDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_type", property = "classTreeType", jdbcType = JdbcType.INTEGER),
            @Result(column = "class_tree_desc", property = "classTreeDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "class_tree_money", property = "classTreeMoney", jdbcType = JdbcType.INTEGER)
    })
    @Select({
            "SELECT * FROM class_type where class_type =#{classType} and class_tree_type =#{classTreeType} limit 1"
    })
    ClassType selectByMoney(@Param("classType")int classType,@Param("classTreeType") int classTreeType);

}
